import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { BatchTaskVO, BatchTaskForm, BatchTaskQuery } from '@/api/agriculture/batchTask/types';

/**
 * 查询批次任务列表
 * @param query
 * @returns {*}
 */

export const listBatchTask = (query?: BatchTaskQuery): AxiosPromise<BatchTaskVO[]> => {
  return request({
    url: '/agriculture/batchTask/list',
    method: 'get',
    params: query
  });
};

// 查询批次任务列表
export function listBatchTaskOfMine(query) {
  return request({
    url: '/agriculture/batchTask/listOfMine',
    method: 'get',
    params: query
  });
}

/**
 * 查询批次任务详细
 * @param taskId
 */
export const getBatchTask = (taskId: string | number): AxiosPromise<BatchTaskVO> => {
  return request({
    url: '/agriculture/batchTask/' + taskId,
    method: 'get'
  });
};

/**
 * 新增批次任务
 * @param data
 */
export const addBatchTask = (data: BatchTaskForm) => {
  return request({
    url: '/agriculture/batchTask',
    method: 'post',
    data: data
  });
};

/**
 * 修改批次任务
 * @param data
 */
export const updateBatchTask = (data: BatchTaskForm) => {
  return request({
    url: '/agriculture/batchTask',
    method: 'put',
    data: data
  });
};

/**
 * 删除批次任务
 * @param taskId
 */
export const delBatchTask = (taskId: string | number | Array<string | number>) => {
  return request({
    url: '/agriculture/batchTask/' + taskId,
    method: 'delete'
  });
};
